import JSEncrypt from 'jsencrypt/bin/jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMq4+u2RsIyMaA146mKQ56OB7GVfz9KTCSOTeroLryJ3ZSYc6W/mjWaf+rSlJAMT55EqUpSHSdG25xkkE92YhPECAwEAAQ=='

const privateKey = 'MIIBVwIBADANBgkqhkiG9w0BAQEFAASCAUEwggE9AgEAAkEAyrj67ZGwjIxoDXjqYpDno4HsZV/P0pMJI5N6uguvIndlJhzpb+aNZp/6tKUkAxPnkSpSlIdJ0bbnGSQT3ZiE8QIDAQABAkEAscp738EHaqx1UWN7hIh7bu4yalIWTSLBQB9G4kX/CiTGdJbyr/LsxIKDrlhqGWL8HvEj9E6kysLcnFJhPMl9dQIhAO156wX29sOSCEoyK165sauKq8wIqD0WRWcDSBPNaDkfAiEA2okT/gyz7I5Vp3/8SG4HztmvsFTV5p9Sl7nmCprhr+8CIQDFOOezQHOX4IP5+siCFv4zVStwfBAdC44AC32k1IamSQIhAKsLhXFfwefSE+qROwX50PSu31sVW4Ixi3SkFRCR3zlTAiEAgIlJ0bACGq326vNXPbkLROJQz3AM0y156PZgGBGWB18='

// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(privateKey)
    return encryptor.decrypt(txt)
}

